package com.doone.ismp.web;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.dispatcher.ServletDispatcherResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.doone.ismp.po.User;
import com.doone.ismp.service.IUserServiceAble;
import com.doone.ismp.service.UserServiceImpl;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @package com.doone.ismp.web
 * @author 甘雨波
 * @date 2009-09-03 上午 09:18
 * @description 测试框架用Action
 *
 */


public class LoginAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	private static Logger log = Logger.getLogger(UserServiceImpl.class);

	@Autowired
	@Qualifier("UserServiceImpl")
	private IUserServiceAble userserivice;

	private String username;

	private String password;

	/**
	 * @author 甘雨波
	 * @date 2009-09-03 上午 09:20
	 * @description 测试框架用Action
	 * @return String
	 */
	//@Action(value = "/login", results = { @Result(name = "success", location = "/results/successPage.jsp") })   
	public String saveUser() {
		log.info(username + "  " + password);
   System.out.println(username + "  " + password);
		User user = new User();
		user.setUserName(username);
		user.setPassWord(password);
		String state = userserivice.saveUser(user);
		if ("S".equals(state)) {
			return "success";
		} else {
			return "error";
		}
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}